package com.dyz.leetcode._06_binarySearch;

public class _852_peakIndexInMountainArray {
    public int peakIndexInMountainArray1(int[] arr) {
        for(int i=0;i<arr.length;i++){
            if(arr[i]>arr[i+1]){return i;}
        }
        return arr.length-1;
    }
    public int peakIndexInMountainArray(int[] arr) {
        int left = 0;
        int right = arr.length-1;
        while(left<right){
            int mid = left + (right-left)/2;
            if(arr[mid]< arr[mid+1]){
                left = mid+1;
            }else{
                right = mid;
            }
        }
        return left;
    }
}
